# 练习题：统计全班的成绩
# 假设一个团队里有5名学员，成绩如下表所示。你可以用NumPy统计下这些人在语文、英语、数学中的平均成绩、最小成绩、最大成绩、方差、标准差。然后把这
# 些人的总成绩排序，得出名次进行成绩输出。
import numpy as np
from operator import attrgetter,itemgetter
schema=np.dtype([("name","U20"),("languageScore","i"),("mathScore","i"),("englishScore","i")])
scoreList=np.array([("张飞",60,30,65),("关羽",95,98,85),("赵云",93,96,92),("黄忠",90,77,88),("典韦",80,90,90)],dtype=schema)
print("语文平均成绩: ",np.mean(scoreList[:]["languageScore"]))
print("语文最低分: ",np.amin(scoreList[:]["languageScore"]))
print("语文高分: ",np.amax(scoreList[:]["languageScore"]))
print("语文方差: ",np.var(scoreList[:]["languageScore"]))
print("语文标准差: ",np.std(scoreList[:]["languageScore"]))
print("------------------------------------------")
print("数学平均成绩: ",np.mean(scoreList[:]["mathScore"]))
print("数学最低分: ",np.amin(scoreList[:]["mathScore"]))
print("数学最高分: ",np.amax(scoreList[:]["mathScore"]))
print("数学方差: ",np.var(scoreList[:]["mathScore"]))
print("数学标准差: ",np.std(scoreList[:]["mathScore"]))
print("------------------------------------------")
print("英语平均成绩: ",np.mean(scoreList[:]["englishScore"]))
print("英语最低分: ",np.amin(scoreList[:]["englishScore"]))
print("英语最高分: ",np.amax(scoreList[:]["englishScore"]))
print("英语方差: ",np.var(scoreList[:]["englishScore"]))
print("英语标准差: ",np.std(scoreList[:]["englishScore"]))
print("------------------------------------------")

#默认升序，指定True为逆序
print(sorted(scoreList,key=lambda x:x[1]+x[2]+x[3],reverse=True))
